<?php
/* ========================================
 * --------------------
 *  controller.php
 * --------------------
 * Created on 22.03.2010
 * ========================================
 * $Revision: $
 * $Author: Dmitry Boycov
 * $HeadURL: $
 * $Id: $
 * ========================================
 * Changes ["date: description (who)"]:
 *
 * 22.03.2010: Original version (WHo)
 * 15:21:00: Time
 */
require_once("app/Controller.php");
require_once("app/Page.php");

class ContactController extends Controller{

	public $tabKey = 'contact';

	/**
	 * construct
	 * @return void
	 */
	public function __construct(){
		parent::__construct();
		$settings = App::settings();
		//check existence needed key in settings
		if(!array_key_exists($this->tabKey,$settings['tabs'])){
			$this->tabKey = null;
		}
	}

	/**
	 * This action is default. And this action generate full page
	 * @return void
	 */
	public function action_execute(){
		$p = new Page();
		if($this->tabKey!=null){
			$cont = $this->getTabContent();
			if(!is_null($this->tabKey)){
				$p->setActiveTab($this->tabKey);
			}
			$tabs = $p->createTabs(array($this->tabKey=>$cont));
			$p->setContent($tabs);
		}
		$p->show();
	}

	private function getTabContent(){
		$settings = App::settings();
		$cont = file_get_contents($settings['templatePath'].'/contact.tpl');
		return $cont;
	}

	/**
	 * This method will be handle ajax request and return content of this tab
	 * @return void
	 */
	public function action_getcontent(){
		if($this->tabKey!=null){
			echo $this->getTabContent();
		}else{
			echo '';
		}
	}
}

?>